package com.julius.design.pattern.filter;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *      年龄过滤器
 * </p>
 */
public class AgeFilter implements Filter{
    @Override
    public List<Person> filter(List<Person> personList) {
        if (personList == null || personList.isEmpty()) {
            return personList;
        }
        List<Person> result = new ArrayList<>();

        for (Person person : personList) {

            if (person.getAge() < 18) {
                continue;
            }
            result.add(person);
        }
        return result;
    }
}
